<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>返利票据基础信息表 管理</title>
		<!-- <style type="text/css">
		</style> -->
		<jsp:include page="../../import.jsp" flush="true" />
</head>

<body class="iframeBody">
	<div class="Wrapper">
		<div class="searchArea">
			<form id="searchBar">
				<div class="fieldset1 clearFix">
					<div class="fieldBox">
						<div class="label">支付表号</div>
						<div class="field">
							<input name="paySchNo" id="paySchNo" type="text"
								class="ui-textbox" value="">
						</div>
					</div>

					<div class="clearFix"></div>
					<div class="btnsBox">
						<span id="searchBtn" class="sq-button sq-button-round">查询</span> <span
							id="clearBtn" class="sq-button sq-button-round">清空</span>
					</div>
				</div>
			</form>
		</div>
		<div id="check_user_emp_bank" class="sq-grid">
			<div id="pageInTab" class="pageInTab">
				<form id="cust_invoice_add_form">
					<div class="fieldset1 tabel_col clearFix">
						<div class="fieldBox col_33">
							<div class="label">返利金额合计</div>
							<div class="field">
								<input id="rbtAmt" type="text" class="ui-textbox" disabled="disabled" value="${rbtAmt }" validate="{required:true, maxlength:60}">
							</div>
						</div>
						<div class="fieldBox col_33">
							<div class="label">开票金额</div>
							<div class="field">
								<input id="billAmt" type="text" class="ui-textbox" disabled="disabled" value="${billAmt }" validate="{required:true, maxlength:60}">
							</div>
						</div>
						<div class="fieldBox col_33">
							<div class="label">开票税点</div>
							<div class="field">
								<input id="billTpAmt" type="text" class="ui-textbox" disabled="disabled" value="${billTpAmt }" validate="{required:true, maxlength:60}">
							</div>
						</div>
					</div>
					<div class="fieldset1 tabel_col clearFix">
						<div class="fieldBox col_33">
							<div class="label">账户名</div>
							<div class="field">
                                <c:if test="${version == 0}">
                                    <input name="rcptUnt" id="rcptUnt" type="text" class="ui-textbox"
                                           value="${rcptUnt }" validate="{required:true, maxlength:20}">
                                </c:if>
                                <c:if test="${version != 0}">
                                    <input name="rcptUnt" id="rcptUnt" type="text" class="ui-textbox"
                                           value="${rcptUnt }" validate="{required:true, maxlength:20}" disabled="disabled">
                                </c:if>
                                <span class="requiredSymbol">*</span>
                            </div>
						</div>
						<div class="fieldBox col_33">
							<div class="label">开户行及支行</div>
							<div class="field">
								<c:if test="${version == 0}">
									<input name="bkNm" id="bkNm" type="text" class="ui-textbox" value="${bkNm }" validate="{required:true,maxlength:60}">
								</c:if>
								<c:if test="${version != 0}">
									<input name="bkNm" id="bkNm" disabled="disabled" type="text" class="ui-textbox" value="${bkNm }" validate="{required:true, maxlength:60}">
								</c:if>
								<span class="requiredSymbol">*</span>
							</div>
						</div>
						<div class="fieldBox col_33">
							<div class="label">开户行账号</div>
							<div class="field">
								<c:if test="${version == 0}">
									<input name="accNo" id="accNo" type="text" class="ui-textbox" value="${accNo }" validate="{required:true,number:true,maxlength:25}">
								</c:if>
								<c:if test="${version !=0}">
									<input name="accNo" id="accNo" disabled="disabled" type="text" class="ui-textbox" value="${accNo }" validate="{required:true, maxlength:25}">
								</c:if>
								<span class="requiredSymbol">*</span>
							</div>
						</div>
						<div class="fieldBox col_33">
							<div class="label">开户行行号</div>
							<div class="field">
								<c:if test="${version == 0 }">
									<input name="bkNo" id="bkNo" type="text" class="ui-textbox" value="${bkNo }" validate="{required:true,number:true,maxlength:30}">
								</c:if>
								<c:if test="${version != 0 }">
									<input name="bkNo" id="bkNo" disabled="disabled" type="text" class="ui-textbox" value="${bkNo }" validate="{required:true,maxlength:30}">
								</c:if>
								<span class="requiredSymbol">*</span>
							</div>
						</div>
					</div>
					<div class="fieldset1 tabel_col clearFix">
						<div class="fieldBox col_33">
							<div class="label">实际付款时间</div>
							<div class="field">
								<c:if test="${version == 1 }">
									<input name="actualPaymentTm" id="actualPaymentTm" type="text" isShow="iscar" class="ui-datepicker" value="${actualPaymentTm}" validate="{required:true}">
								</c:if>
								<c:if test="${version != 1}">
									<input name="actualPaymentTm" id="actualPaymentTm" disabled="disabled" type="text" class="ui-textbox" value="${actualPaymentTm }" validate="{maxlength:30}">
								</c:if>
								<span class="requiredSymbol">*</span>
							</div>
						</div>
						<div class="fieldBox col_33">
							<div class="label">实际付款金额</div>
							<div class="field">
								<c:if test="${version == 1 }">
									<input name="actualPaymentAmt" id="actualPaymentAmt" type="text" class="ui-textbox" value="${actualPaymentAmt }" validate="{required:true,number:true, maxlength:30}">
								</c:if>
								<c:if test="${version != 1}">
									<input name="actualPaymentAmt" id="actualPaymentAmt" disabled="disabled" type="text" class="ui-textbox" value="${actualPaymentAmt }" validate="{maxlength:30}">
								</c:if>
								<span class="requiredSymbol">*</span>
							</div>
						</div>
					</div>
				</form>
				<div class="btnsBox">
					<c:if test="${version == 1 || version == 0 }">
						<span id="savebk" class="sq-button sq-button-round">保存</span>
					</c:if>
				</div>
			</div>
		</div>


		<div id="ligergrid1" class="sq-grid"></div>
	</div>

	<script type="text/javascript">
    var grid = null,callback=null,applyId="${applyId}";
    $(function () {
    	BKform = $("#cust_invoice_add_form").ligerForm({
            validate: true
        });
        grid = $("#ligergrid1").ligerGrid({
            url: '<%=path%>/project/prjRbtbillBscInfo/initList.do?applyId=${applyId}',
            method: 'get',
            columns: [
			{display: '支付表号', name: 'paySchNo', minWidth: 160, align: 'left', enabledSort: false},
			{display: '供应商返利金额', name: 'splRbtAmt', minWidth: 100, align: 'right', 
				render: function (rowdata, index, value) {
			        return '¥'+FormatMoney(rowdata.splRbtAmt/100);
			    },enabledSort: false},
			{display: 'GPS返利金额', name: 'gpsRbtAmt', minWidth: 100, align: 'right',
			    	render: function (rowdata, index, value) {
			            return '¥'+FormatMoney(rowdata.gpsRbtAmt/100);
			        },enabledSort: false},
            {
                display: '销售返利金额', name: 'saleRbtAmt', minWidth: 100, align: 'right',
                render: function (rowdata, index, value) {
                    return '¥' + FormatMoney(rowdata.saleRbtAmt / 100);
                }, enabledSort: false
            },
            {
                display: '供应商阶梯返利金额', name: 'stepRebateAmt', minWidth: 100, align: 'right',
                render: function (rowdata, index, value) {
                    return '¥' + FormatMoney(rowdata.stepRebateAmt / 100);
                }, enabledSort: false
            },
			{display: '狮桥返利', name: '', minWidth: 100, align: 'left', enabledSort: false},
			{display: '起租日', name: 'lsDt', minWidth: 100, align: 'left',render:renderDate, enabledSort: false},
			{display: '项目类型', name: 'prjTypNm', minWidth: 100, align: 'left', enabledSort: false},
			{display: '资管机构', name: 'fundRasInsNm', minWidth: 100, align: 'left', enabledSort: false},
			{display: '所属事业部', name: 'buOrgNm', minWidth: 100, align: 'left', enabledSort: false},
		
            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            checkbox: false,
            rownumbers: true,
            allowUnSelectRow: true,
            alternatingRow: false
        });
        grid.setHeight(100);

        $("#searchBar").ligerForm();

        $("#pageloading").hide();

        /* 查询 */
        $("#searchBtn").click(function (event) {
            var form = liger.get("searchBar");
            var data = form.getData();
            for (name in data) {
                grid.setParm(name, data[name]);
            }
            grid.reload();
        });

        /* 修改与增加 */
        $("#savebk").click(function (event) {
        	 var BKform = liger.get("cust_invoice_add_form");
        	 if (!BKform.valid()) {
	                $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
	                return false; //验证不通过，不执行以下代码
	            }
        	 
             var data = BKform.getData();
             data["actualPaymentTm"] = $("#actualPaymentTm").val();
             $.ligerDialog.confirm(LogUtils.LOG_CMM_SUBMIT_CONFIRM_CONTENT_001, function (flag) {
                 if (flag == false)return;
                 $.ajax({
                     type: 'post',
                     dataType: 'json',
                     data: data,
                     url: '<%=path%>/project/prjRbtbillApply/saveBKinfo.do?applyId='+applyId,
                     success: function (msg) {
                         if (msg.success == 1) {
                             $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                         } else {
                             $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                         }
                     }
                 });
             });
        });
        
        /* 清空 */
        $("#clearBtn").click(function (event) {
            clearLigerForm("searchBar");
        });
        //initData();
    });
  //格式化时间
    function renderDate(rowdata, index, value){
    	var dateStr = "";
    	if(null != value&&value!=''){
    		var date = new Date(value);
    		dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
    	}
    	return dateStr;
    }
    function initData(){
        var _url = '<%=path%>/project/prjRbtbillApply/getById.do';
			//alert(_id);return;//测试
			var _id = applyId;
			$.ajax({
				type : 'get',
				dataType : 'json',
				data : {
					id : _id
				},
				url : _url,
				success : function(msg) {
					if (msg.success == 1) {
						$('#billAmt').html(
								'¥' + FormatMoney(msg.data.billAmt / 100));
						$('#rbtAmt').html(
								'¥' + FormatMoney(msg.data.rbtAmt / 100));
						$('#billTpAmt').html(
								'¥' + FormatMoney(msg.data.billTpAmt / 100));
					} else {
						$.ligerDialog.SQalert({
							content : msg.info,
							SQ_type : "error"
						});
					}
				}
			});
		}
	</script>

</body>
</html>
